# 导⼊JsonResponse类，⽤于处理HTTP响应，返回JSON格式的数据
from django.http import JsonResponse
# 导⼊View类，它是Django中的视图类，⽤于处理Web请求
from django.views import View

from user.models import SysUser


class TestView(View):
    def get(self, request):
        # 获取请求的视图函数
        # 1.查询sys_user表的全部数据
        sys_users = SysUser.objects.all()
        userList_dict = sys_users.values()  # 将查询结果转换成字典
        print("userList_dict:",userList_dict)
        userList = list(userList_dict)  # 将字典转换成列表
        print("userList:",userList)

        return JsonResponse({"code": 200, "info": "请求成功", "data": userList})

























